package guilayer;

import java.awt.BorderLayout;
import java.sql.SQLException;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.TitledBorder;

import modellayer.Invoice;
import controllayer.InvoiceCtr;
import controllayer.SalesOrderCtr;

/**
 * @author Gruppe 3
 *
 */
public class ViewInvoicePanel extends JPanel {
	
	private JPanel viewInvoicePanel;
	
	private JTextField txtInvoiceID,txtInvoiceNo;
	private JTextField txtAmount,txtPaymentDate;
	private JLabel lblAmount,lblPaymentDate;
	private Invoice invoice;

	public ViewInvoicePanel(Invoice invoice) throws SQLException {
		this.invoice = invoice;
		initPanel();
		initComponents(invoice);
		
	}

	/**
	 * Initialize the panel
	 */
	private void initPanel() {
		setLayout(new BorderLayout(0, 0));
		
		viewInvoicePanel = new JPanel();
		viewInvoicePanel.setBorder(new TitledBorder(null, "View invoice", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		add(viewInvoicePanel, BorderLayout.CENTER);
		viewInvoicePanel.setLayout(null);
		
		
	}

	/**
	 * Initialize the components
	 * @param invoice
	 * @throws SQLException
	 */
	private void initComponents(Invoice invoice) throws SQLException {
		JLabel lblInvoiceID = new JLabel("Invoice ID:");
		lblInvoiceID.setBounds(10, 27, 110, 14);
		viewInvoicePanel.add(lblInvoiceID);
		
		txtInvoiceID = new JTextField(Integer.toString(invoice.getInvoiceID()));
		txtInvoiceID.setBounds(130, 24, 214, 20);
		txtInvoiceID.setEditable(false);
		viewInvoicePanel.add(txtInvoiceID);
		txtInvoiceID.setColumns(10);
		
		JLabel lblNo = new JLabel("InvoiceNo:");
		lblNo.setBounds(10, 58, 110, 14);
		viewInvoicePanel.add(lblNo);
		
		txtInvoiceNo = new JTextField(invoice.getInvoiceNo());
		txtInvoiceNo.setColumns(10);
		txtInvoiceNo.setBounds(130, 55, 214, 20);
		txtInvoiceNo.setEditable(false);
		viewInvoicePanel.add(txtInvoiceNo);
		
		txtAmount = new JTextField(invoice.getAmount());
		txtAmount.setEditable(false);
		txtAmount.setColumns(10);
		txtAmount.setBounds(130, 86, 214, 20);
		viewInvoicePanel.add(txtAmount);
		
		txtPaymentDate = new JTextField(invoice.getPaymentDate());
		txtPaymentDate.setEditable(false);
		txtPaymentDate.setColumns(10);
		txtPaymentDate.setBounds(130, 117, 214, 20);
		viewInvoicePanel.add(txtPaymentDate);
		
		lblAmount = new JLabel("Amount:");
		lblAmount.setBounds(10, 89, 110, 14);
		viewInvoicePanel.add(lblAmount);
		
		lblPaymentDate = new JLabel("PaymentDate:");
		lblPaymentDate.setBounds(10, 120, 110, 14);
		viewInvoicePanel.add(lblPaymentDate);

	}
}

